Sometimes, you may want to automatically cancel a job if it takes too long.

One way to do that is to wrap the long-running suspend function in a withTimeout() block. This creates a child job that executes your long-running code, and that job will be canceled if it takes longer than the requested amount of time.

You can learn more about this in:
Tags:
Run Edit